<?php
    $articleModel = new Article();
	$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'articles-grid',
	'dataProvider'=>$articleModel->getArticlesByCatId($model->id),
	#'ajaxUpdate'	=>	'divListCat',
 	'columns'=>array(
		'id',
		array(
			'header' => 'Title',
			'urlExpression'	=>	'Yii::app()->controller->createUrl("article/view",array("id"=>$data->primaryKey))',
			'labelExpression'	=>	'$data->title',
			#'name'			=>	'name',
			'class'			=>	'CLinkColumn',
		),
		'desc',
		'index',
		'special',


		array(
			'class'=>'CButtonColumn',
			'buttons'	=>	array(
				'up'	=>	array(
					'label'	=>	'up',
					'url'	=>	'Yii::app()->controller->createUrl("article/up",array("id"=>$data->id))',
					'imageUrl'	=>	$this->module->assetsUrl . '/images/icon_up.jpg',
					'options'	=>	array(
						'class'	=>	'ajax',
					),
				),
				'down'	=>	array(
					'label'	=>	'down',
					'url'	=>	'Yii::app()->controller->createUrl("article/down",array("id"=>$data->id))',
					'imageUrl'	=>	$this->module->assetsUrl . '/images/icon_down.jpg',
					'options'	=>	array(
						'class'	=>	'ajax',
					),
				),
				'set_special'	=>	array(
					'label'	=>	'set special',
					'url'	=>	'Yii::app()->controller->createUrl("article/setSpecial",array("id"=>$data->id))',
//					'imageUrl'	=>	$this->module->assetsUrl . '/images/icon_down.jpg',
					'options'	=>	array(
						'class'	=>	'ajax',
					),

				),
				'delete_article'	=>	array(
					'label'	=>	'delete',
					'url'	=>	'Yii::app()->controller->createUrl("article/deleteArticle",array("id"=>$data->id))',
					'imageUrl'	=>	$this->module->assetsUrl . '/images/delete.png',
					'options'	=>	array(
						'class'	=>	'ajax',
					),
				),
			),
			'template'	=>	'{set_special}  {up} {down} {delete_article}'		,
			'htmlOptions'	=>	array(
				'width'	=>	'120px',
			),
			'afterDelete'	=>	'function(link, success, data) { ActMsg.showMessage(data); }',
		),
	),
)); ?>

<script language="JavaScript">
<!--
	jQuery(function($) {
	jQuery('#articles-grid a.ajax').live('click',function() {
	var th=this;
	if ($(this).attr('title') == 'delete') if(!confirm('Are you sure you want to delete this item?')) return false;
	$.fn.yiiGridView.update('articles-grid', {
		type:'POST',
		url:$(this).attr('href'),
		success:function(data) {
			ActMsg.showMessage(data);
			$.fn.yiiGridView.update('articles-grid');
		},
	});
	return false;
})});
//-->
</script>
